﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PasteCluster
{
    /// <summary>
    /// 配置信息
    /// </summary>
    public class PasteSloveConfig
    {
        /// <summary>
        /// 集群密钥，防止集群乱入
        /// </summary>
        public string SloveToken { get; set; } = "";

        /// <summary>
        /// 加入到某一个集群 可以为空 多个用;隔开{host},{id},{group};{host},{id},{group}，示例http://172.4.1.5:80;http://172.6.1.8:80
        /// </summary>
        public string ClusterHost { get; set; } = "";

        /// <summary>
        /// 当前节点的访问地址 示例http://192.168.0.5:80
        /// </summary>
        public string CurrentHost { get; set; } = "";

        /// <summary>
        /// 当前节点的随机码，用于查找节点
        /// </summary>
        public string CurrentCode { get; set; } = "";

        /// <summary>
        /// 健康检查间隔5(s)
        /// </summary>
        public int TickSloveHealth { get; set; } = 5;

        /// <summary>
        /// 错误几次的时候 移除这个节点
        /// </summary>
        public int RemoveByTime { get; set; } = 3;

        /// <summary>
        /// 最后交互时间多少10(s)后寻找集群(可能是master掉了)要大于上面那个的2倍
        /// </summary>
        public int TickScanSloveHealth { get; set; } = 10;

        /// <summary>
        /// 子节点消息队列大小 10000
        /// </summary>
        public int SloveChannelMsgCapacity { get; set; } = 10000;

        /// <summary>
        /// 主节点消息队列大小 10000
        /// </summary>
        public int MasterChannelMsgCapacity { get; set; } = 10000;

        /// <summary>
        /// 被问询接口，被其他节点询问当前master是谁 /api/cluster/ask
        /// </summary>
        public string ApiAsk { get; set; } = "/api/cluster/ask";

        /// <summary>
        /// 我参与选举master开始拉票 /api/cluster/vote
        /// </summary>
        public string ApiVote { get; set; } = "/api/cluster/vote";

        /// <summary>
        /// 要求master广播他是master的信息
        /// </summary>
        public string ApiBroad { get; set; } = "/api/cluster/broad";

        /// <summary>
        /// 被检查是否存活 get /api/cluster/health
        /// </summary>
        public string ApiHealth { get; set; } = "/api/cluster/health";

        /// <summary>
        /// 被检查是否存活 post /api/cluster/link
        /// </summary>
        public string ApiLink { get; set; } = "/api/cluster/link";

        /// <summary>
        /// 被通知，哪一个是master /api/cluster/master
        /// </summary>
        public string ApiMaster { get; set; } = "/api/cluster/master";

        /// <summary>
        /// 加入集群，被调用者需要是master /api/cluster/join
        /// </summary>
        public string ApiJoinSlove { get; set; } = "/api/cluster/join";

        /// <summary>
        /// 消息交互 /api/cluster/msg
        /// </summary>
        public string ApiMsg { get; set; } = "/api/cluster/msg";

        /// <summary>
        /// 离开集群 /api/cluster/leave
        /// </summary>
        public string ApiLeave { get; set; } = "/api/cluster/leave";

        /// <summary>
        /// 移除某一个节点 /api/cluster/remove
        /// </summary>
        public string ApiRemove { get; set; } = "/api/cluster/remove";

        /// <summary>
        /// 众多集群列表中不知道哪个是自己的时候需要这个查找 /api/cluster/find
        /// </summary>
        public string ApiFind { get; set; } = "/api/cluster/find";
    }

}
